﻿namespace HashSum
{
    using ImageDupFinder.PluginCore;

    /// <summary>
    /// Class representing "hashsum" plugin for ImageDupFinder program.
    /// </summary>
    public class HashSumPlugin : IPlugin
    {
        /// <summary>
        /// plugin name and description
        /// </summary>
        private string name, description;

        /// <summary>
        /// plugin host
        /// </summary>
        private IPluginHost host;

        /// <summary>
        /// plugin enabled state
        /// </summary>
        private bool enabled;

        /// <summary>
        /// features list.
        /// </summary>
        private string[] featureList;

        /// <summary>
        /// Initializes a new instance of the HashSumPlugin class.
        /// </summary>
        public HashSumPlugin()
        {
            this.name = "Hash Sum";
            this.description = "Compare images using hash sum";
            this.enabled = true;
            this.featureList = new string[] { MD5Sum.FeatureName };
        }

        /// <summary>
        /// Gets plugin name.
        /// </summary>
        public string Name
        {
            get { return this.name; }
        }

        /// <summary>
        /// Gets plugin description.
        /// </summary>
        public string Description
        {
            get { return this.description; }
        }

        /// <summary>
        /// Gets or sets plugin host.
        /// </summary>
        public IPluginHost Host
        {
            get { return this.host; }
            set { this.host = value; }
        }

        /// <summary>
        /// Gets a value indicating whether plugin uses options.
        /// This plugin has no options
        /// </summary>
        public bool HasOptions
        {
            get { return false; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether plugin is in enabled state.
        /// </summary>
        public bool Enabled
        {
            get { return this.enabled; }
            set { this.enabled = value; }
        }

        /// <summary>
        /// Gets features used by this plugin.
        /// </summary>
        public string[] FeatureList
        {
            get { return this.featureList; }
        }

        /// <summary>
        /// Calculates features from this plugin.
        /// </summary>
        /// <param name="image">Image used in feature extraction</param>
        /// <returns>Caltulated features</returns>
        public IFeature[] CalculateFeatures(System.Drawing.Bitmap image)
        {
            IFeature[] retVal = new IFeature[1];
            retVal[0] = new MD5Sum(image);
            return retVal;
        }

        /// <summary>
        /// Not used by this plugin.
        /// </summary>
        public void ShowOptionsDialog()
        {
        }
    }
}
